package com.xiaoha.pogy.services;

import com.xiaoha.pogy.dao.BookRepository;
import com.xiaoha.pogy.entities.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {

    @Autowired
    BookRepository bookRepository;

    public Book save(Book book){
        return bookRepository.save(book);
    }

    public List<Book> getAll(){
        return bookRepository.findAll();
    }

    public Book findByStudentId(long theId) {
        return bookRepository.findByBookId(theId);
    }

    public Book findByBookId(long theId) {
        Book theBook = bookRepository.findByBookId(theId);
        return bookRepository.findByBookId(theId);
    }

    public void delete(Book theBook) {

        bookRepository.delete(theBook);

    }
}
